package com.linran.utils.lock.pojo.result;

import lombok.AllArgsConstructor;
import lombok.Data;

import java.util.concurrent.locks.Lock;

/**
 * 尝试加锁的结果
 *
 * @author daiqi
 * @create 2019-07-28 22:36
 */
@Data
@AllArgsConstructor
public class LockResult {
    protected Lock lock;
    protected boolean result;

    public boolean isSuccess() {
        return this.result;
    }

    public static LockResult succ(Lock lock) {
        return new LockResult(lock, true);
    }

    public static LockResult of(Lock lock, boolean lockResult) {
        return new LockResult(lock, lockResult);
    }
}
